package cn.sunjinxin.trade.domain.model;

import cn.sunjinxin.trade.domain.enums.BizType;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.google.common.collect.Lists;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.FieldDefaults;

import java.util.List;

/**
 * @author issavior
 */
@Data
@FieldDefaults(level = lombok.AccessLevel.PRIVATE)
@NoArgsConstructor
@AllArgsConstructor
public class ProductSpu {

    String productSpuId;

    BizType productBizType;

    String retailPrice;

    Boolean splitOrderMark;

    Long preorderTimeOut;

    List<ProductSku> productSkus;

    public ProductSpu(List<ProductSku> productSkus) {
        this.productSkus = productSkus;
    }

    public ProductSpu of(List<ProductSku> productSkus) {
        this.productSkus = productSkus;
        return this;
    }

    @JsonIgnore
    public Boolean splitFlag() {
        return splitOrderMark && productSkus.size() > 0;
    }

}
